﻿


(function () {
    var ScriptName = "Grid";
    function execute() {
        Type.registerNamespace('Kevin.Controls');
        $Grid = Kevin.Controls.Grid = function (element) {
            $Grid.initializeBase(this, [element]);
            this._QueryControlID = null;
            this._servicePath = null;
            this._queryMethod = null;
            this._gridCssClass = null;
            this._pageSize = 20;
            this._pageIndex = 0;
            this._pageNavigater = null;
            this._topPager = null;
            this._parameters = null;
            this._autoGetData = false;
            this._pagerPlace = Kevin.Controls.PagerPlace.Bottom;
            this._enableSelected = false; //默认不启用选择功能
            this._checkBoxAll = null;
            this._checkBoxItem = null;
            this._selectedDataList = null;
            this._extendGrid = false;
            this._queryParameterValues = "";
            //this._pageNavigater$delegate = { click: Function.createDelegate(this, this._pageNavigaterClick) }
        }

        $Grid.prototype = {

            initialize: function () {
                $Grid.callBaseMethod(this, 'initialize');

                this._pageNavigater = document.createElement("div");
                this._topPager = document.createElement("div");

                _QueryControlClickHandler = Function.createDelegate(this, this._QueryControlClick);
                if (this._QueryControlID) {
                    $addHandler($get(this._QueryControlID), "click", _QueryControlClickHandler);
                }

                _pageNavigaterClickHandler = Function.createDelegate(this, this._pageNavigaterClick);
                $addHandler(this._pageNavigater, "click", _pageNavigaterClickHandler);

                _topPagerClickHandler = Function.createDelegate(this, this._topPagerClick);
                $addHandler(this._topPager, "click", _topPagerClickHandler);

                if (this._autoGetData) {
                    this._pageIndex = 0;
                    this._getData();
                }
            },

            dispose: function () {
                //$clearHandlers(this.get_element());
                $Grid.callBaseMethod(this, 'dispose');

            },
            _QueryControlClick: function () {
                this._pageIndex = 0;
                this._getData();
            },
            _getParameters: function () {
                var paras = {};
                var condition = {};
                this._parameters = {};
                var parasClientState = Sys.Serialization.JavaScriptSerializer.deserialize(this._clientStateField.value).GridQueryParameterList;
                //如果是扩展Grid 参数由请求方来处理
                if (this._queryParameterValues === '') {

                    for (var index in parasClientState) {
                        var method = parasClientState[index].Method;
                        var data = null;
                        if (method) {
                            //自定javasript方法获取控件的值
                            data = window[method].call(this, parasClientState[index].ClientID);
                        } else {
                            data = $KevinXi.getControlValue(parasClientState[index].ClientID);
                        }
                        if (data && data != "") {
                            condition[parasClientState[index].Name] = data;
                        }
                        //condition[parasClientState[index].Name] = eval(parasClientState[index].Method);

                    }
                }
                else {
                    var paraValues = this._queryParameterValues.split(',');
                    for (var index in parasClientState) {
                        condition[parasClientState[index].Name] = paraValues[index];
                    }
                }
                paras.jsonCondition = Sys.Serialization.JavaScriptSerializer.serialize(condition);
                paras.pageIndex = this._pageIndex;
                paras.pageSize = this._pageSize;

                //this._parameters += 'pageIndex:' + this._pageIndex + '\n' + 'pageSize:' + this._pageSize;

                return paras;
            },
            _getData: function () {
                if (this._servicePath && this._queryMethod) {
                    //this._pageIndex = pageIndex;
                    var params = this._getParameters(); //{ jsonEntity: this.getJsonEntity(this._operationMode), operationMode: opMode };
                    //var testpara = { CAF_NO: '9910A' };
                    if (this._webRequest) {
                        // abort the previous web service call if we 
                        // are issuing a new one and the previous one is 
                        // active.
                        this._webRequest.get_executor().abort();
                        this._webRequest = null;

                    }
                    //this._pageIndex = pageIndex;
                    //this.setClientStateNull();
                    this._webRequest = Sys.Net.WebServiceProxy.invoke(this.get_servicePath(), this.get_queryMethod(), false, params,
                                                        Function.createDelegate(this, this._showData),
                                                        Function.createDelegate(this, this._onMethodFailed),
                                                        null);
                }
            },
            _onMethodFailed: function (e) {
                alert(e._message);
            },
            _showData: function (result) {
                if (!result.Successed) {
                    alert(result.ErrorMsg);
                    return;
                }
                var pData = result.List;
                var grid = this.get_element();
                grid.innerHTML = '';

                //如果根据条件没有查询到数据则返回吧
                if (pData == null || pData == '') {
                    grid.innerHTML = '没有找到符合条件的数据!';
                    return;
                }

                var dataFields = Sys.Serialization.JavaScriptSerializer.deserialize(this._clientStateField.value).DataFieldList;
                var editCommand = Sys.Serialization.JavaScriptSerializer.deserialize(this._clientStateField.value).EditCommandFieldStates;
                var strHeader = '';
                var strBody = '';
                var strFooter = '';
                var fieldArray = new Array();
                var field = { FiedlName: "", BindType: 0 };

                strHeader = String.format("<th {0}><input type='checkbox' name='KevinXiCheckBoxAll' onclick='CheckBoxAllClick(\"test\",\"" + this._clientStateField.id + "\",this.checked);' title='全选/撤销全选'/></th>", this._enableSelected == true ? "" : "style='display:none'")
                for (var index in dataFields) {
                    //显示表头
                    var isDisplay = dataFields[index].Visible ? '' : 'style=\'display:none\'';

                    strHeader += String.format("<th {1}>{0}</th>", dataFields[index].HeaderText, isDisplay);
                    //显示明细
                    //strBody += String.format("<td>{0}</td>", dataFileds[index].FiledName);
                    //field.FieldName = dataFields[index].FieldName;
                    //field.BindType = dataFields[index].BindType;
                    fieldArray.push({ FieldName: dataFields[index].FieldName, BindType: dataFields[index].BindType, Visible: dataFields[index].Visible, DataFormat: dataFields[index].DataFormat, Width: dataFields[index].Width });
                }
                if (pData == null || pData == '') {
                    return;
                }
                var data = pData; // Sys.Serialization.JavaScriptSerializer.deserialize(pData);
                var strTR = '';
                var rowNumber = 0;
                for (var index in data) {
                    var reg = new RegExp("\"", "g");
                    var obj = Sys.Serialization.JavaScriptSerializer.serialize(data[index]).replace(reg, "\\\"");
                    rowNumber = rowNumber + 1;
                    strBody += "<tr>";
                    strBody += String.format("<td {0}><input type='checkbox' name='KevinXiCheckBoxItem'  onclick='CheckBoxItemClick(\"{1}\",\"" + this._clientStateField.id + "\",this.checked);' class='{2}'/></td>", this._enableSelected == true ? "" : "style='display:none'", obj, obj);
                    var hasExtend = false; //是否有展开项
                    var extendFiledIndex = 0; //展开项所在位置，如果展开项在第一列，则可以设置缩进
                    var extendTitle = ""; //展开时的提示字符串
                    var extendHiddenTitle = ""; //隐藏时的提示字符串
                    for (var fieldIndex in fieldArray) {

                        //绑定类型
                        var bindType = fieldArray[fieldIndex].BindType
                        //是否显示该列
                        var isDisplay = fieldArray[fieldIndex].Visible == true ? '' : 'style=\'display:none\'';
                        //数据对齐方式
                        var alignType = this._getAlignTypeText(dataFields[fieldIndex].Align);
                        //宽度
                        var width = fieldArray[fieldIndex].Width;

                        isDisplay += this._getWidthText(width);
                        
                        //绑定数据
                        if (bindType == Kevin.Controls.BindType.DataBound) {

                            var _data = data[index][fieldArray[fieldIndex].FieldName];
                            //对于日期，数字若有自定义格式则在此格式化
                            if (dataFields[fieldIndex].DataFormat) {
                                _data = String.format(dataFields[fieldIndex].DataFormat, _data);
                            }
                            strBody += String.format("<td {1} align='{2}' >{0}</td>", _data, isDisplay, alignType);
                        }

                        //绑定操作按钮
                        if (bindType == Kevin.Controls.BindType.CommandField) {
                            var command = "<a href='#' onclick=\"{0}\">{1}</a>";

                            var strItemText = dataFields[fieldIndex].ItemText;
                            strItemText = strItemText.length == null ? "编辑" : strItemText;

                            var strClick = "";
                            //ParentPageControlSetValueMethod

                            if (dataFields[fieldIndex].TagPage == Kevin.Controls.TagPage.Parent) {
                                for (var i in editCommand) {
                                    var strtemp = "String.format(\"" + editCommand[i].Method + "('" + editCommand[i].ClientID + "','{0}',true)\",'" + data.Head[index][editCommand[i].Name] + "')";
                                    strClick += eval(strtemp) + ";"
                                }
                            }
                            else {
                                for (var i in editCommand) {
                                    var strtemp = "String.format(\"" + editCommand[i].Method + "\",'" + data.Head[index][editCommand[i].Name] + "')";
                                    strClick += eval(strtemp) + ";"
                                }
                            }

                            var callBack = dataFields[fieldIndex].CallBack;

                            if (callBack) {
                                strClick += " " + callBack + ";";
                            }
                            //对父页面控件赋值后，本控件所在的DialogWindow应该关闭
                            if (dataFields[fieldIndex].TagPage == Kevin.Controls.TagPage.Parent) {
                                strClick += "window.parent.document.getElementById(window.parent.document.getElementById('DialogWindowIDByKevinXi').value).style.display='none';";
                            }
                            command = String.format(command, strClick, strItemText);
                            strBody += String.format("<td {1} align='{2}'>{0}</td>", command, isDisplay, alignType);
                        }
                        //绑定导航
                        if (bindType == Kevin.Controls.BindType.HyperLink) {
                            var FormatFields = dataFields[fieldIndex].FormatFields.split(',');
                            var strNavigateURL = dataFields[fieldIndex].NavigateURLString;
                            var strItemText = dataFields[fieldIndex].ItemText;
                            strItemText = strItemText == null ? "查看" : strItemText;
                            var strFormat = "";
                            for (var i in FormatFields) {

                                strFormat += "'" + data[index][FormatFields[i]] + "',";
                            }
                            strFormat = strFormat.substring(0, strFormat.length - 1);
                            var strURL = "String.format('" + strNavigateURL + "'," + strFormat + ")";
                            strBody += String.format("<td {2} align='{3}'><a href='{0}'>{1}</a></td>", eval(strURL), strItemText, isDisplay, alignType);
                        }
                        //弹出页面
                        if (bindType == Kevin.Controls.BindType.PopUp) {
                            var FormatFields = dataFields[fieldIndex].FormatFields.split(',');
                            var strNavigateURL = dataFields[fieldIndex].NavigateURLString;
                            var strItemText = dataFields[fieldIndex].ItemText;
                            strItemText = strItemText == null ? data[index][dataFields[fieldIndex].FieldName] : strItemText;
                            var strFormat = "";
                            for (var i in FormatFields) {

                                strFormat += "'" + data[index][FormatFields[i]] + "',";
                            }
                            strFormat = strFormat.substring(0, strFormat.length - 1);
                            var strURL = "String.format('" + strNavigateURL + "'," + strFormat + ")";
                            strURL = eval(strURL);
                            var controlID = 'a' + data[index][dataFields[fieldIndex].FieldName];

                            var Title = dataFields[fieldIndex].DialogTitle;
                            var Width = dataFields[fieldIndex].DialogWidth;
                            var Height = dataFields[fieldIndex].DialogHeight;

                            var strScript = "\"showDialogWindow(this,'" + strURL + "','" + Title + "'," + Width + "," + Height + ",'dialogNormal');return false;\"";
                            strBody += String.format("<td {1} align='{2}'><a href='#'><span id='{3}'  onclick=" + strScript + ">{0}</span></a></td>", strItemText, isDisplay, alignType, controlID);
                        }
                        //收起 展开
                        if (bindType == Kevin.Controls.BindType.Extend) {
                            hasExtend = true;
                            extendFiledIndex = fieldIndex;
                            var templateGridID = dataFields[fieldIndex].GridID;
                            var servicePath = dataFields[fieldIndex].ServicePath;
                            var queryMethod = dataFields[fieldIndex].QueryMethod;
                            var holderParentID = "trExtend" + this.get_element().id + "_" + rowNumber;
                            var holderID = "tdExtend" + this.get_element().id + "_" + rowNumber;
                            /*
                            var clientStateFieldID = holderID + "_ClientState";
                            if ($get(clientStateFieldID) === null) {

                            var clientStateFieldControl = document.createElement("input");
                            clientStateFieldControl.id = clientStateFieldID;
                            clientStateFieldControl.type = "hidden";
                            clientStateFieldControl.value = $get(templateGridID + "_ClientState").value;
                            document.body.appendChild(clientStateFieldControl);
                            }
                            */
                            var formartFiledsList = dataFields[fieldIndex].FormatFileds.split(',');
                            var strQueryValues = '';
                            for (var i in formartFiledsList) {
                                strQueryValues += data[index][formartFiledsList[i]] + ',';
                            }
                            strQueryValues = strQueryValues.substring(0, strQueryValues.length - 1);

                            var subGridCssClassName = dataFields[fieldIndex].SubGridCssClassName
                            extendHiddenTitle = dataFields[fieldIndex].ExtendHiddenTitle;
                            extendTitle = dataFields[fieldIndex].ExtendTitle;
                            if (subGridCssClassName === "") {
                                subGridCssClassName = "GridNormal";
                            }
                            var strScript = String.format("NewGrid(\'{0}\',\'{1}\',\'{2}\',\'{3}\',\'{4}\',\'{5}\',\'{6}\',\'{7}\'); "
                                                            , templateGridID
                                                            , templateGridID + "_ClientState"
                                                            , holderID
                                                            , servicePath
                                                            , queryMethod
                                                            , strQueryValues
                                                            , subGridCssClassName
                                                            , holderParentID);

                            var controlID = this.get_element().id + "_aExtend" + rowNumber;
                            strBody += String.format("<td {1} align='{2}' ><div id='{3}'  onclick=\"{4} ExtendControlClicked(\'{5}\',\'{6}\',\'{7}\'); return false;\" class='GridExtend' title='{8}'>{0}</div></td>", "", isDisplay, alignType, controlID, strScript, controlID, extendTitle, extendHiddenTitle, extendTitle);
                        }
                    }
                    strBody += "</tr>";
                    if (hasExtend) {
                        if (extendFiledIndex === "0") {
                            strBody += "<tr id='trExtend" + this.get_element().id + "_" + rowNumber + "' style='display:none'><td class='' style='border-width:0px;'>&nbsp;</td><td id='tdExtend" + this.get_element().id + "_" + rowNumber + "'  colspan='" + (fieldArray.length - 1) + "' style='padding: 0px; border-bottom-width: 0px; border-right-width: 0px;'></td></tr>";
                        }
                        else {
                            strBody += "<tr id='trExtend" + this.get_element().id + "_" + rowNumber + "' style='display:none'><td id='tdExtend" + this.get_element().id + "_" + rowNumber + "'  colspan='" + fieldArray.length + "' ></td></tr>";
                        }
                    }
                }
                if (!this._gridCssClass)
                    this._gridCssClass = "GridNormal";

                var dataTable = "<table id='TableGrid" + this.get_element().id + "' class='" + this._gridCssClass + "'><thead><tr>" + strHeader + "</tr></thead><tbody>" + strBody + "</tbody><tfoot></tfoot></table>";

                var oldElement = $get("TableGrid" + this.get_element().id);

                if (oldElement) {
                    //LengthAnimation(oldElement, oldElement.width, 0, "width", "left", 1000).start();
                    //LengthAnimation(grid, 0, oldElement.width, "width", "right", 1000).start();
                }
                grid.innerHTML = dataTable;

                this._getPageNavigat(result.RecordCount);
                //grid.innerHTML += pager;
            },
            _getPageNavigat: function (dataRowsCount) {
                //------------------------------------------------------------------------------------------------------
                //Pager
                var pageCount = Math.ceil(dataRowsCount / this._pageSize)
                //如果只有一页的数据就不需要页面导航了
                if (pageCount == 1) return;

                var div_pager = document.createElement("div");


                //                if (this._pageNavigater.addEventListener) {
                //                    this._pageNavigater.addEventListener('click', this._pageNavigaterClick, false);
                //                } else {
                //                    this._pageNavigater.attachEvent('click', this._pageNavigaterClick);
                //                }

                //                 $common.createElementFromTemplate({
                //                    nodeName: "div",
                //                    events: this._pageNavigater$delegate
                //               }, this.get_element());




                var strA = "<a href='#' style='border:1px solid #DDD;background:#F2F2F2;text-decoration:none;margin:1px;' title='{1}'>{0}<a/>";
                var strB = "<font color='red'><b>{0}</b></font>";
                var a_list = "";
                //a_list += "总页数(" + pageCount + ") ";
                var cpage = this._pageIndex + 1;

                if (pageCount <= 10) {        //总页数小于十页 
                    for (count = 1; count <= pageCount; count++) {
                        a_list += (count != cpage) ? String.format(strA, count, count) : String.format(strB, count);
                    }
                }
                if (pageCount > 10) {        //总页数大于十页 
                    if (parseInt((cpage - 1) / 10) == 0) {
                        for (count = 1; count <= 10; count++) {
                            a_list += (count != cpage) ? String.format(strA, count, count) : String.format(strB, count);
                        }
                        a_list += String.format(strA, count, count);
                    }
                    else if (parseInt((cpage - 1) / 10) == parseInt(pageCount / 10)) {
                        a_list += String.format(strA, (parseInt((cpage - 1) / 10) * 10), (parseInt((cpage - 1) / 10) * 10));
                        for (count = parseInt(pageCount / 10) * 10 + 1; count <= pageCount; count++) {
                            a_list += (count != cpage) ? String.format(strA, count, count) : String.format(strB, count);
                        }
                    }
                    else {
                        a_list += String.format(strA, (parseInt((cpage - 1) / 10) * 10), (parseInt((cpage - 1) / 10) * 10));
                        for (count = parseInt((cpage - 1) / 10) * 10 + 1; count <= parseInt((cpage - 1) / 10) * 10 + 10; count++) {
                            a_list += (count != cpage) ? String.format(strA, count, count) : String.format(strB, count);
                        }
                        a_list += String.format(strA, count, count);
                    }
                }
                var aBtn = "{0}";
                var divFirst = "<a href='#' style='border:1px solid #DDD;background:#F2F2F2;text-decoration:none;margin:1px;' class='{0}' title='{1}'>首页<a/>"; //"<img class='{0}' title='首页' index='{1}'></img>";
                var divFirstDisable = "<span>首页</span>";
                var divPrevious = "<a href='#' style='border:1px solid #DDD;background:#F2F2F2;text-decoration:none;margin:1px;' class='{0}' title='{1}'>上一页<a/>"; //"<img class='{0}' title='上一页' index='{1}'></img>";
                var divPreviousDisable = "<span>上一页</span>";
                var divNext = "<a href='#' style='border:1px solid #DDD;background:#F2F2F2;text-decoration:none;margin:1px;' class='{0}' title='{1}'>下一页<a/>"; // "<img class='{0}' title='下一页' index='{1}'></img>";
                var divNextDisable = "<span>下一页</span>";
                var divLast = "<a href='#' style='border:1px solid #DDD;background:#F2F2F2;text-decoration:none;margin:1px;' class='{0}' title='{1}'>末页<a/>"; //"<img class='{0}' title='末页' index='{1}'></img>";
                var divLastDisable = "<span>末页</span>";
                divFirst = cpage == 1 ? divFirstDisable : String.format(divFirst, "FirstPage", String.format(aBtn, 1));
                divPrevious = cpage == 1 ? divPreviousDisable : String.format(divPrevious, "PreviousPage", String.format(aBtn, cpage - 1));
                divNext = cpage == pageCount ? divNextDisable : String.format(divNext, "NextPage", String.format(aBtn, cpage + 1));
                divLast = cpage == pageCount ? divLastDisable : String.format(divLast, "LastPage", String.format(aBtn, pageCount));
                this._pageNavigater.innerHTML = "页次:" + (this._pageIndex + 1) + "/" + pageCount + " 总记录数:" + dataRowsCount + "条  " + divFirst + divPrevious + a_list + divNext + divLast;
                this._pageNavigater.className = 'Pager';
                //this.get_element().appendChild(this._pageNavigater);
                if (this._pagerPlace == Kevin.Controls.PagerPlace.Both) {

                    this.get_element().appendChild(this._pageNavigater);

                    this._topPager.innerHTML = this._pageNavigater.innerHTML;

                    this.get_element().insertBefore(this._topPager, $get('TableGrid' + this.get_element().id));
                }
                if (this._pagerPlace == Kevin.Controls.PagerPlace.Bottom) {
                    this.get_element().appendChild(this._pageNavigater);
                }
                if (this._pagerPlace == Kevin.Controls.PagerPlace.Top) {
                    this.get_element().insertBefore(this._pageNavigater, $get('TableGrid' + this.get_element().id));
                }
                div_pager.innerHTML = a_list;
                return a_list;
                //pager end
                //------------------------------------------------------------------------------------------------------
            },
            _pageNavigaterClick: function (e) {
                var target = e.target;
                if (target && target.tagName == 'A') {
                    this._pageIndex = parseInt(target.title) - 1;
                    this._getData();
                }
                if (target && target.tagName == 'IMG') {
                    if (parseInt(target.index)) {
                        this._pageIndex = parseInt(target.index) - 1;
                        this._getData();
                    }
                }
                return false;
            },
            _topPagerClick: function (e) {
                var target = e.target;
                if (target && target.tagName == 'A') {
                    this._pageIndex = parseInt(target.title) - 1;
                    this._getData();
                }
            },
            _getAlignTypeText: function (align) {

                if (align == Kevin.Controls.AlignType.Left)
                    return 'left';
                if (align == Kevin.Controls.AlignType.Center)
                    return 'center';
                if (align == Kevin.Controls.AlignType.Right)
                    return 'right';

            },
            _getWidthText: function (obj) {
                var result = "";
                if (obj && obj.IsEmpty === false) {

                    if (obj.Type == "7") {
                        result = String.format("style='width:{0}%;'", obj.Value);
                    }
                    else {
                        result = String.format("style='width:{0}px;'", obj.Value);
                    }
                }
                return result;
            },
            _checkBoxAllClick: function () {
                alert('CheckBoxAll Clicked!');
            },
            _checkBoxItemClick: function () {
                alert('CheckBoxItem Clicked!');
            },
            saveClientState: function () {
                var codename = this._txtCode.value.trim();
                var code = codename.substr(codename.lastIndexOf("(") + 1, codename.length - 3);
                var name = codename.substr(0, codename.lastIndexOf("("));
                if (code.endsWith(')')) {
                    code = code.substr(0, code.length - 1);
                }
                var state = {
                    Code: code,
                    Name: name
                };
                //var state = this._txtCode.value;
                return Sys.Serialization.JavaScriptSerializer.serialize(state);
                //return state;
            },
            loadClientState: function () {
                if (this._clientStateField.value == '' || this._clientStateField.value == 'undefined') {
                    return;
                }
                this._clientState = Sys.Serialization.JavaScriptSerializer.deserialize(this._clientStateField.value);
                //this._clientState = this._clientStateField.value;
            },
            get_clientStateField: function () {
                return this._clientStateField;
            },
            set_clientStateField: function (value) {
                if (this._clientStateField != value) {
                    this._clientStateField = value;
                    this.raisePropertyChanged('clientStateField');
                }
            },
            get_QueryControlID: function () {
                return this._QueryControlID;
            },
            set_QueryControlID: function (value) {
                this._QueryControlID = value;
            }, //
            get_AutoGetData: function () {
                return this._autoGetData;
            },
            set_AutoGetData: function (value) {
                this._autoGetData = value;
            },
            get_servicePath: function () {
                return this._servicePath;
            },
            set_servicePath: function (value) {
                this._servicePath = value;
            },
            get_queryMethod: function () {
                return this._queryMethod;
            },
            set_queryMethod: function (value) {
                this._queryMethod = value;
            },
            get_gridCssClass: function () {
                return this._gridCssClass;
            },
            set_gridCssClass: function (value) {
                this._gridCssClass = value;
            }
            ,
            get_pageSize: function () {
                return this._pageSize;
            },
            set_pageSize: function (value) {
                this._pageSize = value;
            },
            get_PagerPlace: function () {
                return this._pagerPlace;
            },
            set_PagerPlace: function (value) {
                this._pagerPlace = value;
            },
            get_EnableSelected: function () {
                return this._enableSelected;
            },
            set_EnableSelected: function (value) {
                this._enableSelected = value;
            },
            get_ExtendGrid: function () {
                return this._ExtendGrid;
            },
            set_ExtendGrid: function (value) {
                this._ExtendGrid = value;
            },
            get_QueryParameterValues: function () {
                return this._queryParameterValues;
            },
            set_QueryParameterValues: function (value) {
                this._queryParameterValues = value;
            }
        }

        $Grid.descriptor = {
            properties: [{ name: 'InsertControlID', type: String}]
        }

        $Grid.registerClass('Kevin.Controls.Grid', Sys.UI.Control);

        //枚举 ： 绑定方式
        Kevin.Controls.BindType = function () {
            throw Error.invalidOperation();
        }
        Kevin.Controls.BindType.prototype = {
            DataBound: 0,
            HyperLink: 1,
            CommandField: 2,
            PopUp: 3,
            Extend: 4
        }
        Kevin.Controls.BindType.registerEnum("Kevin.Controls.BindType", false)

        //枚举 数据对齐方式
        Kevin.Controls.AlignType = function () {
            throw Error.invalidOperation();
        }
        Kevin.Controls.AlignType.prototype = {
            Left: 0,
            Center: 1,
            Right: 2
        }
        Kevin.Controls.AlignType.registerEnum("Kevin.Controls.AlignType", false)

        //枚举 给控件赋值时 控件所在页面是当前页面或父页面
        Kevin.Controls.TagPage = function () {
            throw Error.invalidOperation();
        }
        Kevin.Controls.TagPage.prototype = {
            Current: 0,
            Parent: 1
        }
        Kevin.Controls.TagPage.registerEnum("Kevin.Controls.TagPage", false)

        //枚举 分页导航显示的位置
        Kevin.Controls.PagerPlace = function () {
            throw Error.invalidOperation();
        }
        Kevin.Controls.PagerPlace.prototype = {
            Top: 0,
            Bottom: 1,
            Both: 2
        }
        Kevin.Controls.PagerPlace.registerEnum("Kevin.Controls.PagerPlace", false)

    } //execute

    if (window.Sys && Sys.loader) {
        Sys.loader.registerScript(ScriptName, ["ExtendedModalPopup"], null, execute);

    }
    else {
        execute();
    }

})();
//if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();